import axios from "./axios";
import { processResponse } from "./util";

export default {
  // 上传课件
  dictionary(lesson, query) {
    return processResponse(axios.get("/dictionary/" + lesson, { query }));
  },
  // app获取list
  appList(query) {
    return processResponse(axios.get("/app/query", { query }));
  },
  // app添加
  appAdd(query) {
    return processResponse(axios.post("/app", query));
  },
  // app获取id信息
  appGet(id, query) {
    return processResponse(axios.get("/app/" + id, query));
  },
  // app更新
  appPut(query) {
    return processResponse(axios.put("/app/", query));
  },
  // app删除
  appDelete(id, query) {
    return processResponse(axios.delete("/app/" + id, query));
  },
  // 资料列表
  materialList(query) {
    return processResponse(
      axios.get("/material/query/by-app?page=0&size=10", { params: query })
    );
  },

  saveAppInfo(query) {
    if (query.oid) {
      return processResponse(axios.put("/app", query));
    } else {
      return processResponse(axios.post("/app", query));
    }
  },
  // 资料新增
  saveMaterial(query) {
    if (query.oid) {
      return processResponse(axios.put("/material", query));
    } else {
      return processResponse(axios.post("/material", query));
    }
  },
  // 资料id信息
  materialIdShow(id, query) {
    return processResponse(axios.get("/material/" + id, query));
  },
  // 资料删除
  materialDelete(id, query) {
    return processResponse(axios.delete("/material/" + id, query));
  },
  // 课程获取list
  courseList(query) {
    return processResponse(
      axios.get("/course/query?page=0&size=10", { query })
    );
  },
  // 课程新增
  courseAdd(query) {
    return processResponse(axios.post("/course", query));
  },
  // 课程编辑
  courseEdit(query) {
    return processResponse(axios.put("/course", query));
  },
  // 课程id获取信息
  courseGet(id, query) {
    return processResponse(axios.get("/course/details/" + id, { query }));
  },
  // 课程id删除
  courseDelete(id, query) {
    return processResponse(axios.delete("/course/" + id, { query }));
  },
  // 上传课件
  courseWareAdd(query) {
    return processResponse(axios.post("/course-content", query));
  },
  // 课程分页请求
  coursePage(page, size, query) {
    return processResponse(
      axios.get("/course/query?page=" + page + "&size=" + size, {
        params: query
      })
    );
  },
  // 资料分页请求
  materialPage(page, size, query) {
    return processResponse(
      axios.get("/material/query?page=" + page + "&size=" + size, {
        params: query
      })
    );
  },
  // 课程批量删除
  coruseBatchDelete(data, query) {
    return processResponse(axios.get("/course/delete/oids?" + data, { query }));
  },
  // 资料批量删除
  materialBatchDelete(data, query) {
    return processResponse(
      axios.get("/material/delete/oids?" + data, { query })
    );
  },
  // 课程课件id删除
  courseShowDelete(id, query) {
    return processResponse(axios.delete("/course-content/" + id, { query }));
  }
};
